import 'package:app_core/src/app/config.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';

/// 全局静态数据
class SystemSetting {
  /// 初始化
  static Future init() async {
    await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
    appGlobalConfig.appConfig.isDarkStatusBar ? setDarkSystemUi() : setLightSystemUi();
  }

  static SystemUiOverlayStyle get darkSystemUiOverlayStyle {
    if (GetPlatform.isAndroid) {
      return const SystemUiOverlayStyle(
        statusBarColor: Colors.transparent,
        statusBarBrightness: Brightness.dark,
        statusBarIconBrightness: Brightness.dark,
        systemNavigationBarDividerColor: Colors.transparent,
        systemNavigationBarColor: Colors.white,
        systemNavigationBarIconBrightness: Brightness.dark,
      );
    } else {
      return SystemUiOverlayStyle.dark;
    }
  }

  static SystemUiOverlayStyle get lightSystemUiOverlayStyle {
    if (GetPlatform.isAndroid) {
      return const SystemUiOverlayStyle(
        statusBarColor: Colors.transparent,
        statusBarBrightness: Brightness.dark,
        statusBarIconBrightness: Brightness.dark,
        systemNavigationBarDividerColor: Colors.transparent,
        systemNavigationBarColor: Colors.white,
        systemNavigationBarIconBrightness: Brightness.dark,
      );
    } else {
      return SystemUiOverlayStyle.light;
    }
  }

  static void setDarkSystemUi() {
    SystemChrome.setSystemUIOverlayStyle(darkSystemUiOverlayStyle);
  }

  static void setLightSystemUi() {
    SystemChrome.setSystemUIOverlayStyle(lightSystemUiOverlayStyle);
  }
}
